package org.zhxy.core.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.zhxy.common.aop.AutomaticLog;
import org.zhxy.common.config.ServiceFactory;
import org.zhxy.common.response.Result;
import org.zhxy.common.response.ResultCode;
import org.zhxy.core.system.service.UserService;
import org.zhxy.entity.system.User;
import org.zhxy.entity.system.UserMaterial;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {


    @AutomaticLog("修改用户的启禁状态")
    @RequestMapping(value = "/updateStatusForUser",method = RequestMethod.POST)
    public Result updateStatusForUser(@RequestBody User user){
        return ServiceFactory.userService.updateStatusForUser(user);
    }

    @AutomaticLog("上传用户资料照片")
    @RequestMapping(value = "/uploadImage",method = RequestMethod.POST)
    public Result uploadImage(@RequestParam("file") MultipartFile file, @RequestParam("id")String id) throws IOException {
        return ServiceFactory.userService.uploadImage(file,id);
    }

    @AutomaticLog("获取用户的资料图片集合")
    @RequestMapping(value = "/getUserImageList/{userId}",method = RequestMethod.GET)
    public Result getUserImageList(@PathVariable("userId")String userId){
        return Result.SUCCESS_NO_MESSAGE(ServiceFactory.userService.getUserImageList(userId));
    }

    @AutomaticLog("删除用户的资料图片")
    @RequestMapping(value = "/removeUserImage/{id}",method = RequestMethod.GET)
    public Result removeUserImage(@PathVariable("id")String id){
        return ServiceFactory.userService.removeUserImage(id);
    }
}
